/*
 * @Author: Lauxb
 * @Date: 2021-03-17 15:31:58
 * @LastEditTime: 2021-12-22 18:02:41
 * @LastEditors: Please set LastEditors
 * @Description: 定位、飞行方法
 */

import store from "@/store";

/**
 * 默认视图
 * @param {*} chaos 全局三维管理器
 */
export const locateDefaultView = (chaos, duration = 1.0) => {
  const camara = store.getters["scene/camara"];
  const pos = new chaos.cesium.Cartesian3(camara.x, camara.y, camara.z);
  const pos2 = chaos.cesium.Cartesian3.fromDegrees(119.2546, 29.8609, 390000)
  const params = {
    destination: store.state.threeplans.sceneViewerMap === 0 ? pos : pos2,
    duration: duration,
    complete() { }
  };
  if (
    camara &&
    camara.heading !== undefined &&
    camara.pitch !== undefined &&
    camara.roll !== undefined
  ) {
    params.orientation = {
      heading: camara.heading,
      pitch: camara.pitch,
      roll: camara.roll
    };
  }
  chaos.viewer.camera.setView(params);
};
